import {
  FlowNodeInputTypeEnum,
  FlowNodeTemplateTypeEnum,
  FlowNodeTypeEnum,
  WorkflowIOValueTypeEnum,
} from '@/types/workflow/constant';
import { FlowNodeTemplateType } from '@/types/workflow/node';
import { getHandleConfig } from '../../utils';

export const SmtpModule: FlowNodeTemplateType = {
  id: FlowNodeTypeEnum.smtp,
  templateType: FlowNodeTemplateTypeEnum.communication,
  flowNodeType: FlowNodeTypeEnum.pluginModule,
  sourceHandle: getHandleConfig(true, true, true, true),
  targetHandle: getHandleConfig(true, true, true, true),
  avatar: 'smtp.svg',
  name: '邮件发送',
  intro: '通过SMTP发送电子邮件。',
  showStatus: false,
  isTool: true,
  courseUrl: '/docs/workflow/modules/ai_chat/',
  version: '481',
  isFolded: true,
  pluginId: 'community-smtp',
  inputs: [
    {
      key: 'smtpHost',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: 'SMTP主机',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'smtpPort',
      renderTypeList: [FlowNodeInputTypeEnum.numberInput, FlowNodeInputTypeEnum.reference],
      label: 'SMTP端口',
      toolDescription: 'SMTP端口',
      required: true,
      value: '',
      valueType: WorkflowIOValueTypeEnum.number,
      selectedTypeIndex: 0,
      canEdit: false,
      defaultValue: '465',
    },
    {
      key: 'smtpUser',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: 'SMTP用户名',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'smtpPass',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: 'SMTP密码',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'fromName',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: '发件人名称',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      maxLength: 200,
      canEdit: false,
      required: true,
    },
    {
      key: 'to',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: '收件人',
      description: '多个收件人用逗号分隔',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'subject',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: '邮件主题',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'content',
      renderTypeList: [FlowNodeInputTypeEnum.JSONEditor, FlowNodeInputTypeEnum.reference],
      label: '邮件内容',
      value: '',
      placeholder: '请输入邮件内容',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: true,
    },
    {
      key: 'cc',
      renderTypeList: [FlowNodeInputTypeEnum.input, FlowNodeInputTypeEnum.reference],
      label: '抄送对象',
      description: '多个抄送对象用逗号分隔',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: false,
    },
    {
      key: 'bcc',
      renderTypeList: [FlowNodeInputTypeEnum.hidden],
      label: '密送对象',
      description: '多个密送对象用逗号分隔',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      required: false,
    },
    {
      key: 'attachments',
      renderTypeList: [FlowNodeInputTypeEnum.hidden],
      label: '附件',
      value: '',
      valueType: WorkflowIOValueTypeEnum.string,
      selectedTypeIndex: 0,
      canEdit: false,
      customInputConfig: {
        selectValueTypeList: [WorkflowIOValueTypeEnum.arrayObject],
      },
    },
  ],
  outputs: [],
};
